The invention relates in general to computer software, and in particular to improving the efficiency of repeated execution of established program modules.
Application programs are generally built from software components comprising routines within libraries. These routines may be used and re-used as often as a particular application program requires. The program modules may be stored separately from the application program in shared libraries or in archive libraries within the application program.
Shared libraries generally contain routines which may be potentially be accessed by a number of different application programs. The routines are generally sufficiently modular that they may be used with a range of different application programs and operate compatibly with all of them. Examples of such program modules include sine and cosine functions among other standard mathematical operations usable by a variety of application programs.
Shared libraries offer the advantage of occupying less disk space and using less RAM at run-time than if the various libraries were initially included in the various main application programs. Further, program modules in shared libraries may be updated and improved independently of the application programs which make calls to the shared libraries. In this manner, the operation of programs calling the updated routines may be improved without changing the calling program.
The application programs and the various libraries are generally compiled separately. In order for the application programs to call the libraries or routines contained therein at run-time, link tables are established in both the application programs and the libraries. Generally, compilation of the shared library routines generate relocatable files. For the routine to be executed at run-time, a link table in the calling program or application program must be filled with information indicating the actual memory location of the desired library or routine. Generally, any call to a shared library routine involves loading the routine""s address from the linkage table and branching to this address, which is generally time consuming. Accordingly, routines in shared libraries generally execute more slowly than equivalent routines initially incorporated into the application program. In addition to the link table requirements, compile time optimizations between the main application program code and the shared library routine code are generally not available since the routines are compiled separately. This unavailability of compile time optimizations tends to add the execution speed disadvantage of shared library routines.
Another way to store commonly used program modules is to link them directly with the application program. Routines stored in an archive library of an application program are generally combined with the application program thereby forming a single self-contained program. Employing a single program with all routines included generally provides the application program with all required address information for the archived routines thereby obviating the need for the creation of linking tables and the need to load addresses from this table for each library routine call. Generally, a further benefit arises from the availability of compile time optimizations when using libraries archived within the application program which are generally not available when the archive libraries and application program are located in independent files and are compiled independently.
Application programs with archived libraries therefore generally execute more rapidly than an application which makes calls to shared libraries. Archive libraries however, generally occupy more disk space than shared libraries since each library will generally be stored along with each application program which places the library in its archive. Programs with archive libraries also generally require more RAM at run-time than programs employing shared libraries. Furthermore, shared libraries generally present the benefit of modularity. Specifically, shared libraries may be updated independently of the application programs which call them. In order to update a library archived within an application program, the entire program would generally have to be relinked with the new library. Accordingly, in the prior art, the user is presented with a choice between a modular shared routine which takes up little disk space but executes slowly and an archived routine which takes up more disk space but executes rapidly.
Therefore, there is a need in the art for re-usable library routines to execute rapidly while minimizing the demands on disk space and RAM memory during run-time.
These and other objects, features and technical advantages are achieved by a system and method which copies selected shared library routines into an original application program to create a new executable, in the form of an optimized application program, thereby providing for more rapid execution of the combination of original application code and the copied shared library routines. Preferably, system behavior with respect to the shared libraries is preserved when employing the present invention. Where several versions of a shared library exist on a computer system and a particular application program requires one specific version among the several versions, an application program optimized according to the mechanism of the present invention preferably selects the same specific version of the shared library as the original unoptimized version.
In a preferred embodiment, the inventive system and method preferably preserve an original version of the application program. The inventive system and method may then determine, based on the needs of a particular application, whether the new or original application program is best suited for the task. If a task does not require the incorporated shared library routines, the original application program will preferably be employed. Where a task requires one or more library routines which have been copied into an optimized program, the optimized application program will be employed.
As used herein, the term xe2x80x9cincorporatingxe2x80x9d refers to a process of copying a shared library or a routine within a shared library into an original application program and re-linking the combination of the original application program code and the copied shared library code to produce a new executable to be known as an optimized version of that application program. The term xe2x80x9ccode of interestxe2x80x9d applies to code in the shared libraries which is a candidate for being copied or incorporated into a calling application program because such code satisfies one or more factors favoring such incorporation.
Preferably, various different application programs may be optimized, enabling various different optimized application programs, corresponding to different original application programs, to co-exist on the system at any one time. Further, a single original application program may be optimized differently by copying different selections of shared libraries or shared library routines along with the original application program code, thereby enabling a number of different optimized versions of the same original application program to co-exist in the system at any one time. Although different versions of an optimized program may co-exist within an overall computer system, where two optimized programs differ only in the respect that one of the programs has more recent versions of certain library routines copied, the program with the outdated libraries will preferably be deleted in order to preserve disk space on the system.
Generally, while copying shared library routines into application programs causes the routines to execute more rapidly, such copying also generally occupies more disk space and more RAM at run-time. Copying no routines at all would generally present no burden on RAM and disk space but would also generally cause no improvement in execution speed. On the other hand, copying an excessive number of shared library routines would generally require an unacceptable amount of disk space and RAM. Accordingly, the present invention is selective with respect to the routines which are copied into application programs so as to balance the objectives of rapid execution and efficient utilization of RAM and disk space.
As used herein, the term xe2x80x9csystemxe2x80x9d generally refers to an overall computer system optionally including both hardware and software. The terms xe2x80x9capplicationxe2x80x9d or xe2x80x9ctaskxe2x80x9d refer to an operation to be performed by the system. The term xe2x80x9capplication programxe2x80x9d refers to a specific block of code which may be employed to perform a required function within the system. It is noted that, at any one time, there may be more than one application program capable of performing a function or operation required by the system. The term xe2x80x9capplication programxe2x80x9d generally refers to an original application program which generally does not have archived libraries and functions by making calls to shared libraries. The term xe2x80x9coptimized application programsxe2x80x9d refers to original application programs into which code from shared libraries or shared library routines have been copied so as to achieve superior performance.
In a preferred embodiment, a number of different optimized application programs with different sets of routines taken from previously shared libraries, and now copied into executable application programs, will be available for execution depending on the needs of a particular application or task. The inventive mechanism preferably logs the different application programs and the routines archived within them so as to select the application program best suited for a particular task.
Generally, executing shared library routines requires that the computer system executing the application program fill linkage tables with address information for both executable code and data used by the program. The process of supplying data to the linking tables is generally necessary each time a shared library routine is loaded for execution by the computer system. Each call to a shared library routine involves loading the address of the routine from the linkage table and transferring control to this address. However, once a shared library routine is copied into an application program, the address locations for the code within the copied routine are known, and program execution is not burdened with the need to look up the addresses of shared library routines in order to call them. Although address locations for executable code in a copied routine are generally known, address information for data to be accessed by the copied routine or library may still have to be looked up at run-time.
In an alternative embodiment, rather than copying shared library routines so as to resolve the addresses of executable code but not those of data tables, the application program could be relinked with the archive versions of the libraries it uses. Linking with the archive libraries preferably enables all required address information (that is, for data tables as well as executable code) to be supplied to the link tables. Preferably such fully archived routines operate just as they would if the code for the routine had been present in the application program when the application program was first compiled.
In a preferred embodiment, the computer system may select from among several optimized application programs which have varying sets of routines copied into them. Preferably, the libraries and/or routines required for a task are compared with those routines which have been copied into various optimized application programs to ensure a proper match. If the versions of routines needed by a task do not match those which have been copied into existing optimized programs, the system may choose to load the unoptimized application program and call the appropriate shared libraries. Alternatively, the system may copy the desired routines into the application program thereby creating a new optimized application program if circumstances otherwise warrant copying of the desired routines.
In a preferred embodiment, the inventive system and method includes a mechanism for identifying those shared library routines which are preferred candidates for being copied into an optimized application program. Factors which may be used to identify such preferred candidates include but are not limited to: the frequency of execution of the routine, the time required for execution of the shared routine, the time required for execution of the routine once archived, and an estimated improvement in overall application program efficiency resulting from copying of each routine. The inventive system and method preferably have the ability to incorporate additional shared library routines as a need for such incorporation becomes apparent.
In a preferred embodiment, the inventive system and method includes a mechanism for identifying application programs which are preferred candidates for optimization. Factors which may be used to identify such preferred candidates include but are not limited to: execution efficiency of the original application program, frequency of execution of the application program, frequency of calls to shared library routines, and the total amount of time devoted to the application program by the computer system.
In a preferred embodiment, an optimizer is employed which is capable of performing optimizations other than copying shared libraries into original application programs. Additional possible optimizations include code layout and hot-cold optimizations. Preferably, optimizations are performed during computer system idle time to as to minimize any interference with application programs. Preferably, the various optimizations all contribute to enabling the optimized programs to execute as rapidly as possible while minimizing the burden on disk space and RAM.
Therefore, it is an advantage of the present invention that optimized programs execute more rapidly than original application programs.
It is a further advantage of the present invention that shared library routines may be screened for copying into application programs to avoid excessive consumption of disk space and RAM at run-time.
It is a still further advantage of the present invention that application programs may be screened for factors favoring selection for optimization thereby improving execution speed while avoiding placing excessive demands on RAM and disk space.
The foregoing has outlined rather broadly the features and technical advantages of the present invention in order that the detailed description of the invention that follows may be better understood. Additional features and advantages of the invention will be described hereinafter which form the subject of the claims of the invention. It should be appreciated by those skilled in the art that the conception and specific embodiment disclosed may be readily utilized as a basis for modifying or designing other structures for carrying out the same purposes of the present invention. It should also be realized by those skilled in the art that such equivalent constructions do not depart from the spirit and scope of the invention as set forth in the appended claims.